package com.sxf.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

/**
 * 与文章有关的分类、来自wp_terms表的tags以及这一关联存于此表中. 链接与各自分类的联系也在此
 * 
 * @author phsxf01
 * 
 */
@Entity
@Table(name = "wp_term_relationships")
@DynamicInsert
@DynamicUpdate
public class TermRelationships implements Serializable {
	@Id
	@Column(name="object_id")
	private Long objectId;// 为post中的id
	
	@Id
	@Column(name="term_taxonomy_id")
	private Long termTaxonomyId;

	// objectId,termTaxonomyId 联合主键

	@Column(name="term_order")
	private Integer termOrder;

	private static final long serialVersionUID = 1L;

	public TermRelationships() {

	}

	public Long getObjectId() {
		return objectId;
	}

	public void setObjectId(Long objectId) {
		this.objectId = objectId;
	}

	public Long getTermTaxonomyId() {
		return termTaxonomyId;
	}

	public void setTermTaxonomyId(Long termTaxonomyId) {
		this.termTaxonomyId = termTaxonomyId;
	}

	public Integer getTermOrder() {
		return termOrder;
	}

	public void setTermOrder(Integer termOrder) {
		this.termOrder = termOrder;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((objectId == null) ? 0 : objectId.hashCode());
		result = prime * result
				+ ((termTaxonomyId == null) ? 0 : termTaxonomyId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TermRelationships other = (TermRelationships) obj;
		if (objectId == null) {
			if (other.objectId != null)
				return false;
		} else if (!objectId.equals(other.objectId))
			return false;
		if (termTaxonomyId == null) {
			if (other.termTaxonomyId != null)
				return false;
		} else if (!termTaxonomyId.equals(other.termTaxonomyId))
			return false;
		return true;
	}

}
